<?php
$url = '?md=' . MvcReg::$_moduleName . '&cl=' . MvcReg::$_controllerName . '&at=' . str_replace('add', '', MvcReg::$_actionName) . 'update';

?>
<!doctype html>
<html>
<head>
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width,initial-scale=1">
    <?php include_once MvcReg::$_moduleName . '/views/layout/head.php'; ?>
    <style>
        #main .right-content{min-height: 1500px}
    </style>
</head>
<body>
<?php include_once MvcReg::$_moduleName . '/views/layout/woody-prompt.php'; ?>
<?php include_once MvcReg::$_moduleName . '/views/layout/header.php'; ?>
<link rel="stylesheet" href="webroot/common/jquery-ui-timepicker-addon.min.css"/>
<div id="main">
    <div class="container-fluid">
        <div class="row">
            <div class="col-md-2">
                <?php include_once MvcReg::$_moduleName . '/views/layout/left_menu.php'; ?>
            </div>
            <div class="col-md-10">
                <div class="right-content">
                    <a href="?md=store&cl=riders&at=riders_audit_list&page=<?php echo $page?>"  class="btn btn-white btn-xs pull-right goback floatright">返回上一级</a>
                    <h3>
                        <ol class="breadcrumb"><li><a href="?md=store&cl=riders&at=riders_audit_list&page=<?php echo $page?>"><i class="fa fa-dashboard"></i><?php echo $menu["breadcrumb_current"]?></a><li class="active">查看</li></li></ol>
                    </h3>
                    <div class="col-sm-10">
                        <div class="wrapper wrapper-content animated fadeInUp">
                            <div class="ibox">
                                <div class="ibox-content" >
                                    <form class="form-horizontal" method="post" action="<?php echo $url?>" enctype="multipart/form-data" autocomplete="off">
                                        <input type="hidden" name="service_shop_no" value="<?php echo $rsp_list['service_shop_no'];?>">
                                        <input type="hidden" name="id" value="<?php echo $rsp_list['id'];?>">
                                        <input type="hidden" name="province" id="province" value="<?php echo $rsp_list['province'];?>">
                                        <input type="hidden" name="city" id="city" value="<?php echo $rsp_list['city'];?>">
                                        <input type="hidden" name="area" id="area" value="<?php echo $rsp_list['area'];?>">

                                        <input type="hidden" name="service_province" id="service_province" value="<?php echo $rsp_list['service_province'];?>">
                                        <input type="hidden" name="service_city" id="service_city" value="<?php echo $rsp_list['service_city'];?>">
                                        <input type="hidden" name="service_rea" id="service_area" value="<?php echo $rsp_list['service_area'];?>">
                                        <div class="form-group">
                                            <label class="col-sm-3 control-label">姓名：</label>
                                            <div class="col-sm-5">
                                                <input type="text" placeholder="姓名" name="name" class="form-control" value="<?php echo $rsp_list['name'];?>">
                                            </div>
                                        </div>

                                        <div class="form-group">
                                            <label class="col-sm-3 control-label">昵称：</label>
                                            <div class="col-sm-5">
                                                <input type="text" placeholder="昵称" name="username" class="form-control" value="<?php echo $rsp_list['username'];?>">
                                            </div>
                                        </div>


                                        <?php if($rsp_list['sex'] == 1){$n = "checked='checked'";}else{$nv = "checked='checked'";}?>
                                        <div class="form-group">
                                            <label class="col-sm-3 control-label">性别：</label>
                                            <div class="col-sm-5">
                                                <label style=" line-height: 30px; margin:0 10px 0 0"><input type="radio"   value="1" <?php echo $n;?> name="sex">  男</label>
                                                <label style=" line-height: 30px; margin:0 10px 0 0"><input type="radio"  value="0" <?php echo $nv;?>  name="sex">  女</label>
                                            </div>
                                        </div>

                                        <div class="form-group">
                                            <label class="col-sm-3 control-label">出生年月：</label>
                                            <div class="col-sm-5">
                                                <input type="text" placeholder="出生年月" class="form-control date form_datetime"  name="birth_date" value="<?php echo $rsp_list['birth_date'];?>">
                                            </div>
                                        </div>

                                        <div class="form-group">
                                            <label class="col-sm-3 control-label">年龄：</label>
                                            <div class="col-sm-5">
                                                <input type="text" placeholder="年龄" class="form-control" name="age" value="<?php echo $rsp_list['age'];?>">
                                            </div>
                                        </div>

                                        <div class="form-group">
                                            <label class="col-sm-3 control-label">联系电话：</label>
                                            <div class="col-sm-5">
                                                <input type="text" placeholder="联系电话" class="form-control" name="tel" value="<?php echo $rsp_list['tel'];?>" readonly>
                                            </div>
                                        </div>

                                        <div class="form-group">
                                            <label class="col-sm-3 control-label">常住地址：</label>
                                            <div class="col-sm-3">
                                                <select name="province" id="provinces" style="width: 160px;"></select>
                                            </div>

                                            <div class="col-sm-3" style="width: 15%;margin-left: -40px;">
                                                <select name="city" id="citys" style="width: 160px;"></select>
                                            </div>

                                            <div class="col-sm-3" style="width: 15%;margin-left: 40px;">
                                                <select name="area" id="areas" style="width: 160px;"></select>
                                            </div>
                                        </div>

                                        <div class="form-group">
                                            <label class="col-sm-3 control-label"></label>
                                            <div class="col-sm-5">
                                                <input type="text" placeholder="常住地址" class="form-control" name="address" value="<?php echo $rsp_list['address'];?>">
                                            </div>
                                        </div>

                                        <div class="form-group">
                                            <label class="col-sm-3 control-label">服务城市：</label>
                                            <div class="col-sm-3">
                                                <select name="service_province" id="service_provinces" style="width: 160px;"></select>
                                            </div>

                                            <div class="col-sm-3" style="width: 15%;margin-left: -40px;">
                                                <select name="service_city" id="service_citys" style="width: 160px;"></select>
                                            </div>

                                            <div class="col-sm-3" style="width: 15%;margin-left: 40px;">
                                                <select name="service_area" id="service_areas" style="width: 160px;"></select>
                                            </div>
                                        </div>

                                        <div class="form-group">
                                            <label class="col-sm-3 control-label">服务门店：</label>
                                            <div class="col-sm-5">
                                                <input type="text" placeholder="" class="form-control" id="service_shop_no1" name="" value="<?php echo $rsp_list['shop_name'];?>">
                                                <select name="service_shop_no" id="service_shop_no" style="width: 160px;display: none"></select>
                                            </div>
                                        </div>

                                        <div class="form-group">
                                            <label class="col-sm-3 control-label">身份证号码：</label>
                                            <div class="col-sm-5">
                                                <input type="text" placeholder="身份证号码" class="form-control" name="id_card" value="<?php echo $rsp_list['id_card'];?>">
                                            </div>
                                        </div>

                                        <div class="form-group">
                                            <label class="col-sm-3 control-label">身份证（正面）：</label>
                                            <div class="col-sm-5">
                                                <div class="input-group" >
                                                    <!--                                                    $('#sf_card_front').click();"-->
                                                    <img src="webroot/file/riders/<?php echo $rsp_list['card_front_img'];?>" id="img_card_front1" alt="" style="width: 85%;height:170px;"> <span class="input-group-btn"><input type="file" style="display: none" name="card_front_img" id="uploadImg1" multiple="multiple" accept="image/*"> <button type="button"  onclick="uplodImg(1)" class="btn btn-w-m btn-success">重新上传</button> </span>
                                                </div>
                                            </div>
                                        </div>
                                        <div class="form-group">
                                            <label class="col-sm-3 control-label"></label>
                                            <div class="col-sm-5">
                                                <div id="demo1"></div>
                                            </div>
                                        </div>

                                        <div class="form-group">
                                            <label class="col-sm-3 control-label">身份证（反面）：</label>
                                            <div class="col-sm-5">
                                                <div class="input-group" >
                                                    <img src="webroot/file/riders/<?php echo $rsp_list['card_back_img'];?>" id="img_card_front2" alt="" style="width: 85%;height:170px;"> <span class="input-group-btn"><input type="file" style="display: none" name="card_back_img" id="uploadImg2" multiple="multiple" accept="image/*"> <button type="button" onclick="uplodImg(2)" class="btn btn-w-m btn-success">重新上传</button> </span>
                                                </div>
                                            </div>
                                        </div>
                                        <div class="form-group">
                                            <label class="col-sm-3 control-label"></label>
                                            <div class="col-sm-5">
                                                <div id="demo2"></div>
                                            </div>
                                        </div>

                                        <div class="form-group">
                                            <label class="col-sm-3 control-label">健康证：</label>
                                            <div class="col-sm-5">
                                                <div class="input-group" >
                                                    <img src="webroot/file/riders/<?php echo $rsp_list['health_cards'];?>" id="img_card_front3" alt="" style="width: 85%;height:170px;"> <span class="input-group-btn"><input type="file" style="display: none" name="health_cards" id="uploadImg3" multiple="multiple" accept="image/*"> <button type="button"  onclick="uplodImg(3)" class="btn btn-w-m btn-success">重新上传</button> </span>
                                                </div>
                                            </div>
                                        </div>


                                        <div class="form-group">
                                            <label class="col-sm-3 control-label">健康证起始时间</label>
                                            <div class="col-sm-5">
                                                <input type="text" placeholder="" class="form-control" value="<?php echo strstr($rsp_list['jkz_start'],' ', true);?>  至 <?php echo strstr($rsp_list['jkz_end'],' ', true);?>">
                                            </div>
                                        </div>


                                        <div class="form-group">
                                            <label class="col-sm-3 control-label"></label>
                                            <div class="col-sm-5">
                                                <div id="demo3"></div>
                                            </div>
                                        </div>

                                        <div class="form-group">
                                            <label class="col-sm-3 control-label">简历：</label>
                                            <div class="col-sm-5">
                                                <textarea name="resume" id="" class="form-control"  style="width: 100%;height: 120px;"><?php echo $rsp_list['resume'];?></textarea>
                                            </div>
                                        </div>

                                        <div class="form-group">
                                            <label class="col-sm-3 control-label">紧急联系人：</label>
                                            <div class="col-sm-5">
                                                <input type="text" placeholder="紧急联系人" name="urgency_cont_username" class="form-control" value="<?php echo $rsp_list['urgency_cont_username'];?>">
                                            </div>
                                        </div>

                                        <div class="form-group">
                                            <label class="col-sm-3 control-label">紧急联系人电话：</label>
                                            <div class="col-sm-5">
                                                <input type="text" placeholder="紧急联系人电话" name="urgency_cont_username_tel" class="form-control" value="<?php echo $rsp_list['urgency_cont_username_tel'];?>">
                                            </div>
                                        </div>

                                        <div class="form-group">
                                            <label class="col-sm-3 control-label">与本人关系：</label>
                                            <div class="col-sm-5">
                                                <input type="text" placeholder="与本人关系" name="urgency_relation" class="form-control" value="<?php echo $rsp_list['urgency_relation'];?>">
                                            </div>
                                        </div>

                                        <div class="form-group">
                                            <label style="margin-right: 20px;" class=" col-sm-3 control-label">审核:</label>
                                            <label class="radio-inline">
                                                <input type="radio"  value="1" checked name="audit">通过
                                            </label>
                                            <label class="radio-inline">
                                                <input type="radio"  value="3" name="audit">未通过
                                            </label>
                                        </div>


                                        <div class="form-group" style="display: none">
                                            <label class="col-sm-3 control-label">审核未通过备注：</label>
                                            <div class="col-sm-5">
                                                <input type="text" placeholder="请审核未通过备注" name="remark" value="" class="form-control">
                                            </div>
                                        </div>

                                        <div class="form-group">
                                            <div class="col-sm-offset-3 col-sm-5">
                                                <button type="button" class="btn btn-w-m btn-warning">取  消</button>
                                                <button type="submit" class="btn btn-primary">保  存</button>
                                            </div>
                                        </div>
                                    </form>
                                </div>
                            </div>
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </div>

<!------------------------------------------ 常住地址 --------------------------------------------->
    <script type="text/javascript">
        $("#provinces").off("change").on("change",function(){
            var code = $(this).val();
            var city = '';
            $.ajax({
                url:"?md=manage&cl=riders&at=getCity",
                type:"post",
                dataType:"json",
                data:{'code':code},
                success:function (d) {
                    $("#citys").html('');
                    if(d.status == 1){
                        city+='<option  name="city" value="">请选择...</option>';
                        $("#areas").html('<option  name="area" value="">请选择...</option>');
                        $(d.city).each(function (k,v) {
                            city+='<option  name="city" value="'+v.code+'">'+v.fullname+'</option>';
                        });
                        $("#citys").html(city);
                    }
                }
            })
        });

        $("#citys").off("change").on("change",function(){
            var acode = $(this).val();
            var areas = '';
            $.ajax({
                url:"?md=manage&cl=riders&at=getArea",
                type:"post",
                dataType:"json",
                data:{'code':acode},
                success:function (d) {
                    if(d.status == 1){
                        areas+='<option name="area" value="">请选择...</option>';
                        $(d.area).each(function (k,v) {
                            areas+='<option  name="area" value="'+v.code+'">'+v.fullname+'</option>';
                        });
                        $("#areas").html(areas);
                    }
                }
            })
        });

    </script>

    <!------------------------------------------ 服务地址 --------------------------------------------->
    <script type="text/javascript">
        $("#service_provinces").off("change").on("change",function(){
            $("#service_shop_no").show();
            $("#service_shop_no").html('<option  name="province" value="">请选择...</option>');
            $("#service_shop_no1").hide();
            var code = $(this).val();
            var city = '';
            $.ajax({
                url:"?md=manage&cl=riders&at=getCity",
                type:"post",
                dataType:"json",
                data:{'code':code},
                success:function (d) {
                    $("#service_citys").html('');
                    $("#service_areas").html('');
                    if(d.status == 1){
                        city+='<option  name="province" value="">请选择...</option>';
                        $("#service_areas").html('<option  name="area" value="">请选择...</option>');
                        $(d.city).each(function (k,v) {
                            city+='<option  name="province" value="'+v.code+'">'+v.fullname+'</option>';
                        });
                        $("#service_citys").html(city);
                    }
                }
            })
        });

        $("#service_citys").off("change").on("change",function(){
            $("#service_shop_no").show();
            $("#service_shop_no").html('<option  name="province" value="">请选择...</option>');
            $("#service_shop_no1").hide();
            var acode = $(this).val();
            var areas = '';
            $.ajax({
                url:"?md=manage&cl=riders&at=getArea",
                type:"post",
                dataType:"json",
                data:{'code':acode},
                success:function (d) {
                    $("#service_areas").html('');
                    if(d.status == 1){
                        areas+='<option name="area" value="">请选择...</option>';
                        $(d.area).each(function (k,v) {
                            areas+='<option  name="area" value="'+v.code+'">'+v.fullname+'</option>';
                        });
                        $("#service_areas").html(areas);
                    }
                }
            })
        });

        // 获取门店信息
        $("#service_areas").off("change").on("change",function(){
            $("#service_shop_no").show();
            $("#service_shop_no").html('<option  name="province" value="">请选择...</option>');
            $("#service_shop_no1").hide();
            var acode = $(this).val();
            var shops = '';
            $.ajax({
                url:"?md=manage&cl=riders&at=getShop",
                type:"post",
                dataType:"json",
                data:{'code':acode},
                success:function (d) {
                    if(d.status == 1){
                        shops+='<option name="area" value="">请选择...</option>';
                        if(d.shop){
                            $("#service_shop_no").attr('disabled',false);
                            $(d.shop).each(function (k,v) {
                                shops+='<option  name="area" value="'+v.store_id+'">'+v.storename+'</option>';
                            });
                            $("#service_shop_no").html(shops);
                        }else{
                            $("#service_shop_no").html(shops);
                            $("#service_shop_no").attr('disabled',true)
                        }

                    }
                }
            })
        });

        $(function(){
            var service_province = $("#service_province").val();
            var service_city = $("#service_city").val();
            var service_area = $("#service_area").val();
            var service_provinceHtml = '';
            var service_cityHtml = '';
            var service_areaHtml = '';
            var service_checkedP = "";
            var service_checkedC = "";
            var service_checkedA = "";
            $.ajax({
                url:"?md=manage&cl=riders&at=getSAllArea",
                type:"post",
                dataType:"json",
                data:{'service_city':service_city,'service_area':service_area,'service_province':service_province},
                success:function (d) {
                    $(d.province).each(function (kp,vp) {
                        if(vp.code == service_province){
                            service_checkedP = "selected='selected'";
                        }else{
                            service_checkedP = '';
                        }
                        service_provinceHtml+='<option '+service_checkedP+' name="province" value="'+vp.code+'">'+vp.fullname+'</option>'
                    });

                    $(d.city).each(function (kc,vc) {
                        if(vc.code == service_city){
                            console.log(vc.code);
                            service_checkedC = "selected='selected'";
                        }else{
                            service_checkedC = '';
                        }
                        service_cityHtml+='<option '+service_checkedC+' name="province" value="'+vc.code+'">'+vc.fullname+'</option>'
                    });

                     $(d.area).each(function (ka,va) {
                        if(va.code == service_area){
                            service_checkedA = "selected='selected'";
                        }else{
                            service_checkedA = '';
                        }
                         service_areaHtml+='<option '+service_checkedA+' name="province" value="'+va.code+'">'+va.fullname+'</option>'
                    });



                    // service_cityHtml+='<option  name="province" value="'+d.city['code']+'">'+d.city['fullname']+'</option>';
                    // service_areaHtml+='<option  name="province" value="'+d.area['code']+'">'+d.area['fullname']+'</option>';

                    $("#service_provinces").html(service_provinceHtml);
                    $("#service_citys").html(service_cityHtml);
                    $("#service_areas").html(service_areaHtml);
                }
            });
        });
    </script>

    <script>
        $("input[name=audit]").change(function () {
            var audit =  $("input[name=audit]:checked").val();
            if(audit == 3){
                $(this).parent().parent().next().show();
                $(this).parent().parent().next().attr('required',true);
            }else{
                $(this).parent().parent().next().attr('required',false);
                $(this).parent().parent().next().hide();
            }
        });

        $(function(){
            var province = $("#province").val();
            var city = $("#city").val();
            var area = $("#area").val();
            var provinceHtml = '';
            var cityHtml = '';
            var areaHtml = '';
            var checkedP = "";
            var checkedC = "";
            var checkedA = "";
            $.ajax({
                url:"?md=manage&cl=riders&at=getAllArea",
                type:"post",
                dataType:"json",
                data:{'city':city,'area':area,'province':province},
                success:function (d) {
                    $(d.province).each(function (kp,vp) {
                        if(vp.code == province){
                            checkedP = "selected='selected'";
                        }else{
                            checkedP = '';
                        }
                        provinceHtml+='<option '+checkedP+' name="province" value="'+vp.code+'">'+vp.fullname+'</option>'
                    });


                    $(d.city).each(function (kc,vc) {
                        if(vc.code == city){
                            checkedC = "selected='selected'";
                        }else{
                            checkedC = '';
                        }
                        cityHtml+='<option '+checkedC+' name="province" value="'+vc.code+'">'+vc.fullname+'</option>'
                    });

                    $(d.area).each(function (ka,va) {
                        if(va.code == area){
                            checkedA = "selected='selected'";
                        }else{
                            checkedA = '';
                        }
                        areaHtml+='<option '+checkedA+' name="province" value="'+va.code+'">'+va.fullname+'</option>'
                    });


                    // cityHtml+='<option  name="province" value="'+d.city['code']+'">'+d.city['fullname']+'</option>';
                    // areaHtml+='<option  name="province" value="'+d.area['code']+'">'+d.area['fullname']+'</option>';

                    $("#provinces").html(provinceHtml);
                    $("#citys").html(cityHtml);
                    $("#areas").html(areaHtml);
                }
            });
        unlink();
        });

        function unlink() {
            $.ajax({
                url: "?md=manage&cl=riders&at=unlinkImage",
                dataType: "json",
                type: "post",
            });
        }


        function uplodImg(num){
            if(num){
                $("#uploadImg"+num).click();
                $("#uploadImg"+num).off('change').on('change', function() {
                    var animateimg = $(this).val();
                    var imgarr = animateimg.split('\\');
                    var myimg = imgarr[imgarr.length-1];
                    var houzui = myimg.lastIndexOf('.');
                    var ext = myimg.substring(houzui, myimg.length).toUpperCase();
                    var file = $(this).get(0).files[0];
                    var formData = new FormData();
                    formData.append('file',file);
                    if(ext !='.PNG' && ext !='.GIF' && ext !='.JPG' && ext !='.JPEG' && ext !='.BMP'){
                        alert("图片格式错误，请重新上传！");
                        return;
                    }

                    $.ajax({
                        url: "?md=manage&cl=riders&at=getImage",
                        dataType: "json",
                        type: "post",
                        processData: false,
                        contentType: false,
                        data:formData,
                        xhr: function(){
                            myXhr = $.ajaxSettings.xhr();
                            if(myXhr.upload){
                                myXhr.upload.addEventListener('progress',function(e){
                                    if(e.lengthComputable){
                                        var percent = Math.floor(e.loaded / e.total*100);
                                        $("#demo"+num).css('background-color','green');
                                        $("#demo"+num).css('width',String(percent)+'%');
                                        $("#demo"+num).html(String(percent)+'%');
                                    }
                                }, false);
                            }
                            return myXhr;
                        },
                        success: function (d) {
                            jQuery("#demo"+num).hide();
                            if(d.status == 1){
                                $("#img_card_front"+num).attr('src',d.img);
                            }else{
                                alert('...');
                            }
                        }
                    });
                });

            }
        }
        $(".form_datetime").datepicker({format: 'yyyy-mm-dd'});
    </script>

    <?php include_once MvcReg::$_moduleName . '/views/layout/footer.php'; ?>
    <?php include_once MvcReg::$_moduleName . '/views/order/order_delivery_infoView.php'; ?>
</body>
</html>
